kind: pipeline
type: docker
name: default

steps:
- name: build
  # Do not show red cross even if exit is run
  failure: ignore
  image: node:lts-alpine
  commands:
  # Tests if there are changes except Drone builds and
  # stops from repeated builds if there aren't.
  - apk add --no-cache git
  - V=$(git log --pretty='format:%s' -1)
  - V=$(echo $V | sed '/^Drone build/d')
  - test -z $V && exit 1
  # Continue build for new changes as usual.
  - cd src
  - npm install hexo-cli -g
  - test -e package.json && npm install
  - hexo generate
  - cd ..

- name: push commit
  image: appleboy/drone-git-push
  settings:
    branch: main
    remote: git@codeberg.org:hexo-test/pages.git
    force: false
    commit: true
    commit_message: "Drone build ${DRONE_COMMIT_SHA:0:7}"
    author_name: "John Doe"
    author_email: "example@email.com"
    ssh_key:
      from_secret: ssh_key
  # To show green check in case previous step exits.
  when:
    status:
    - success
